# vim: ts=4:sw=4:syntax=perl
# CSS-V1

sub mm_outstanding_approvals_summary_headers($) {
my ($order_by)=@_;

	my $d;
	if(exists($::ENV{PATH_INFO}) && length($::ENV{PATH_INFO})>1) {
		$d="../images";
	} else {
		$d="images";
	}

	if($order_by eq "?order_by - not defined?") {
		$order_by="id";
	}
	#################################################################
	# If the value specified is not recognised then default to name	#
	#################################################################
	my @S=qw(id date requester portal rid rdate rrequester rportal);
	if(! grep {$_ eq $order_by} @S) {
		$order_by="id";
	}
	my $s="";
	my $s1="<td width=15% class=gri_cell>";
	$s=$s1;

	if($order_by eq "id") {
		my $l=link_to_str("headinglink","Request ID","outstanding_approvals_summary","order_by=rid");
		$s.=$l . "&nbsp;&nbsp;<img src=\"$d/down_16.png\"></td>";
	} else {
		my $l=link_to_str("headinglink","Request ID","outstanding_approvals_summary","order_by=id");
		$s.=$l;
		if($order_by eq "rid") {
			$s.="&nbsp;&nbsp;<img src=\"$d/up_16.png\">";
		}
		$s.="</td>";
	}

	$s1="<td class=gri_cell width=15%>";
	$s.=$s1;
	if($order_by eq "date") {
		my $l=link_to_str("headinglink","Date","outstanding_approvals_summary","order_by=rdate");
		$s.=$l . "&nbsp;&nbsp;<img src=\"$d/down_16.png\"></td>";
	} else {
		my $l=link_to_str("headinglink","Date","outstanding_approvals_summary","order_by=date");
		$s.=$l . "&nbsp;&nbsp;";
		if($order_by eq "rdate") {
			$s.="<img src=\"$d/up_16.png\">";
		}
		$s.="</td>";
	}

	$s1="<td class=gri_cell width=35%>";
	$s.=$s1;
	if($order_by eq "requester") {
		my $l=link_to_str("headinglink","Requester","outstanding_approvals_summary","order_by=rrequester");
		$s.=$l . "&nbsp;&nbsp;<img src=\"$d/down_16.png\"</td>";
	} else {
		my $l=link_to_str("headinglink","Requester","outstanding_approvals_summary","order_by=requester");
		$s.=$l . "&nbsp;&nbsp;";
		if($order_by eq "rrequester") {
			$s.="<img src=\"$d/up_16.png\">";
		}
		$s.="</td>";
	}

	$s1="<td class=gri_cell width=25%>";
	$s.=$s1;
	if($order_by eq "portal") {
		my $l=link_to_str("headinglink","Portal","outstanding_approvals_summary","order_by=rportal");
		$s.=$l . "&nbsp;&nbsp;<img src=\"$d/down_16.png\"</td>";
	} else {
		my $l=link_to_str("headinglink","Portal","outstanding_approvals_summary","order_by=portal");
		$s.=$l . "&nbsp;&nbsp;";
		if($order_by eq "rportal") {
			$s.="<img src=\"$d/up_16.png\">";
		}
		$s.="</td>";
	}
	$s1="<td class=gri_cell-right width=10%>View</td>\n";
	$s.=$s1;

	return $s;
}
